insert overwrite table jms_dws.dws_waybill_day_cnt_dt partition(dt)
    select
         dt                         as input_date
        ,pick_network_code          as pick_network_code
        ,max(pick_network_name)     as pick_network_name
        ,waybill_source_code        as waybill_source_code
        ,max(waybill_source_name)   as waybill_source_name
        ,sender_province_name       as sender_province_name
        ,sender_city_name           as sender_city_name
        ,sender_area_name           as sender_area_name
        ,franchisee_code            as franchisee_code
        ,max(franchisee_name)       as franchisee_name
        ,agent_code                 as agent_code
        ,max(agent_name)            as agent_name
        ,sum(cnt)                   as cnt
        ,dt
from jms_dws.dws_waybill_hour_cnt_dt
where dt = '{{ execution_date | cst_ds }}'
group by dt
        ,pick_network_code
        ,waybill_source_code
        ,sender_province_name
        ,sender_city_name
        ,sender_area_name
        ,franchisee_code
        ,agent_code
distribute by 1 ;
